package servlet.PropertyManagementModule.ExpenseTypeManagement;

import bean.vo.ExpenseTypeOption;
import com.alibaba.fastjson.JSON;
import commons.r.R;
import service.ExpenseTypeService;
import service.impl.ExpenseTypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * servlet.PropertyManagementModule.ExpenseTypeManagement
 * User: xlh
 * Date: 2024/12/17 14:51
 * motto:推到高塔
 * Description:
 * Version: V1.0
 */
@WebServlet(name="ExpenseTypeListServlet",value="/expenseType/findAllList")
@MultipartConfig
public class ExpenseTypeListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
        ExpenseTypeService expenseTypeService=new ExpenseTypeServiceImpl();
        List<ExpenseTypeOption> list= expenseTypeService.findAllList();
        R r;
        r=list!=null?R.ok(list):R.ok("没有种类数据");
        PrintWriter writer = response.getWriter();
        String  result= JSON.toJSONString(r);
        System.out.println("FindAllListServlet:"+result);
        writer.write(result);
        writer.flush();
        writer.close();
    }
}
